package com.xczl.demo.test;

import java.util.List;

import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;

import com.xczl.demo.dao.UserDao;
import com.xczl.demo.domain.User;

@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration({ "classpath:root-context.xml" })
public class UserTestCase {

	@Autowired
	private UserDao userDao;

	@Test
	public void insert(){
		User user = new User();
		user.setUserId(22);
		user.setLevelId(3);
		user.setName("小7");
		user.setSex(0);
		user.setUserName("user22");
		user.setPassword("123456");
		userDao.insertUser(user);
	}
	
	@Test
	public void findById(){
		User user = userDao.findById(15);
		System.out.println(user.getName());
	}
	
	@Test
	public void findAll(){
		List<User> goodscateList = userDao.findAll();
		for(User temp:goodscateList){
			System.out.println(temp.getName());
		}

}
}
